{template header}

<style>
    .hp-visited a:visited{color: #444;}
    .input-append button{font-size:12px;}
    select,.f12{font-size:12px;}
    #no_user,#user_show{display:none;}
</style>
<div style="clear:both">
    <h5>
        <span class="add-on"><i class="icon-calendar"></i> {if $isNew}创建{else}修改{/if}群组信息 </span>
        <span class="add-on">
            <code><a href="./?c=admin&a=GroupList">返回群组列表</a></code>
        </span>
    </h5>
</div>

<table class="table table-striped table-bordered table-hover" height="700"><tr><td>
<div style="clear:both;margin: 50px;">
    {if !empty($msg)}
    <div class="alert alert-warn">
        {$msg}
    </div>
    {/if}
    <form class="form-horizontal" method="post" enctype="multipart/form-data">
        <div class="control-group">
            <label class="control-label" for="uid">群主UID </label>
            <div class="controls">
                <div><input class="input-small" name="uid" type="text" id="uid" placeholder="群主Uid" value="{$groupInfo['uid']}" style="font-size:12px;"> <code id="no_user">这个用户被你吃掉了！</code>
                <span id="user_show"><img width="20" id="user_header" src="" /> <code id="user_name" style="color:#333"></code></span></div>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="name">群组名 </label>
            <div class="controls">
                <input name="name" type="text" id="name" placeholder="群组名" value="{$groupInfo['name']}" style="font-size:12px;">
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="hupu_username">群组LOGO </label>
            <div class="controls">
                <div>
                    {if $groupInfo['sourceImg']}<div style="margin-top:5px;"><img width="100" height="100" src="{$groupInfo['sourceImg']}" border="0" /></div>{/if}
                </div>
                <div style="margin-top:10px">
                    <input name="header" type="file" style="font-size:12px;" />
                </div>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="hupu_username">群组宣言 </label>
            <div class="controls">
                <input name="slogan" class="input-xxlarge" type="text" id="slogan" placeholder="群组宣言" value="{$groupInfo['slogan']}" style="font-size:12px;">
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="province_city">所属省市 </label>
            <div class="controls">
                <input type="hidden" id="province_de" value="{$groupInfo['province']}">
                <input type="hidden" id="city_de" value="{$groupInfo['city']}">
                <select class="input-small" name="province" id="province">
                    <option value="" {if !$groupInfo['province']}selected="selected"{/if}>未选择省份</option>
                </select>
                <select class="input-small" name="city" id="city">
                    <option value="" {if !$groupInfo['city']}selected="selected"{/if}>未选择城市</option>
                </select>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="member_limit">成员数上限 </label>
            <div class="controls">
                <select name="member_limit" class="input-small" id="member_limit">
                    <option value="500" {if !$groupInfo['member_limit']}selected="selected"{/if}>500人</option>
                    <option value="1000" {if $groupInfo['member_limit'] == 1000}selected="selected"{/if}>1000人</option>
                    <option value="1500" {if $groupInfo['member_limit'] == 1500}selected="selected"{/if}>1500人</option>
                    <option value="2000" {if $groupInfo['member_limit'] == 2000}selected="selected"{/if}>2000人</option>
                    <option value="2500" {if $groupInfo['member_limit'] == 2500}selected="selected"{/if}>2500人</option>
                    <option value="3000" {if $groupInfo['member_limit'] == 3000}selected="selected"{/if}>3000人</option>
                </select>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="isverify">验证方式</label>
            <div class="controls">
                <select name="isverify" class="input-medium" id="isverify">
                    <option value="0" {if !$groupInfo['isverify']}selected="selected"{/if}>需要群主验证后加入</option>
                    <option value="1" {if $groupInfo['isverify'] == 1}selected="selected"{/if}>任何人直接加入</option>
                </select>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="isDismiss">状态</label>
            <div class="controls">
                <select name="isDismiss" class="input-small" id="isDismiss">
                    <option value="0" {if !$groupInfo['isDismiss']}selected="selected"{/if}>正常</option>
                    <option value="1" {if $groupInfo['isDismiss'] == 1}selected="selected"{/if}>已解散</option>
                </select>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="inputStatus"></label>
            <div class="controls">
                <input type="submit" id="inputSubmit" class="btn btn-primary" value="提交">&nbsp;&nbsp;
                <input type="reset" id="inputreset" class="btn btn-inverse" value="重置">
            </div>
        </div>
    </form>
</div>
</td></tr></table>

<script type="text/javascript">

$(function(){
    $('#province').on('change', in_city);
    in_province();

    $('#uid').on('blur', in_user_show);
    in_user_show();
});

var last_uid = 0;

var is_in_province = false;

var provinces = ["北京","天津","河北","山西","内蒙古","辽宁","吉林","黑龙江","上海","江苏","浙江","安徽","福建","江西","山东","河南","湖北","湖南","广东","广西","海南","重庆","四川","贵州","云南","西藏","陕西","甘肃","青海","宁夏","新疆","台湾","香港","澳门","海外"];

var citys = {
    "北京": ["东城区","西城区","朝阳区","丰台区","石景山区","海淀区","门头沟区","房山区","通州区","顺义区","昌平区","大兴区","怀柔区","平谷区","密云县"],
    "天津": ["和平区","河东区","河西区","南开区","河北区","红桥区","东丽区","西青区","津南区","北辰区","武清区","宝坻区","滨海新区","宁河县","静海县","蓟县"],
    "河北": ["石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水"],
    "山西": ["太原","大同","阳泉","长治","晋城","朔州","晋中","运城","忻州","临汾","吕梁"],
    "内蒙古": ["呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔","巴彦淖尔","乌兰察布","兴安盟","锡林郭勒","阿拉善盟"],
    "辽宁": ["沈阳","大连","鞍山","抚顺","本溪","丹东","锦州","营口","阜新","辽阳","盘锦","铁岭","朝阳","葫芦岛"],
    "吉林": ["长春","吉林","四平","辽源","通化","白山","松原","白城","延边朝鲜族自治州"],
    "黑龙江": ["哈尔滨","齐齐哈尔","鸡西","鹤岗","双鸭山","大庆","伊春","佳木斯","七台河","牡丹江","黑河","绥化","大兴安岭地区"],
    "上海": ["黄浦区","徐汇区","长宁区","静安区","普陀区","闸北区","虹口区","杨浦区","闵行区","宝山区","嘉定区","浦东新区","金山区","松江区","青浦区","奉贤区","崇明县"],
    "江苏": ["南京","无锡","徐州","常州","苏州","南通","连云港","淮安","盐城","扬州","镇江","泰州","宿迁"],
    "浙江": ["杭州","宁波","温州","嘉兴","湖州","绍兴","金华","衢州","舟山","台州","丽水"],
    "安徽": ["合肥","芜湖","蚌埠","淮南","马鞍山","淮北","铜陵","安庆","黄山","滁州","阜阳","宿州","六安","亳州","池州","宣城"],
    "福建": ["福州","厦门","莆田","三明","泉州","漳州","南平","龙岩","宁德"],
    "江西": ["南昌","景德镇","萍乡","九江","新余","鹰潭","赣州","吉安","宜春","抚州","上饶"],
    "山东": ["济南","青岛","淄博","枣庄","东营","烟台","潍坊","济宁","泰安","威海","日照","莱芜","临沂","德州","聊城","滨州","菏泽"],
    "河南": ["郑州","开封","洛阳","平顶山","安阳","鹤壁","新乡","焦作","濮阳","许昌","漯河","三门峡","南阳","商丘","信阳","周口","驻马店"],
    "湖北": ["武汉","黄石","十堰","宜昌","襄阳","鄂州","荆门","孝感","荆州","黄冈","咸宁","随州","恩施土家族苗族自治州"],
    "湖南": ["长沙","株洲","湘潭","衡阳","邵阳","岳阳","常德","张家界","益阳","郴州","永州","怀化","娄底","湘西"],
    "广东": ["广州","韶关","深圳","珠海","汕头","佛山","江门","湛江","茂名","肇庆","惠州","梅州","汕尾","河源","阳江","清远","东莞","中山","潮州","揭阳","云浮"],
    "广西": ["南宁","柳州","桂林","梧州","北海","防城港","钦州","贵港","玉林","百色","贺州","河池","来宾","崇左"],
    "海南": ["海口","三亚"],
    "重庆": ["万州区","涪陵区","渝中区","大渡口区","江北区","沙坪坝区","九龙坡区","南岸区","北碚区","綦江区","大足区","渝北区","巴南区","黔江区","长寿区","江津区","合川区","永川区","南川区","璧山区","铜梁区","潼南县","荣昌县","梁平县","城口县","丰都县","垫江县","武隆县","忠县","开县","云阳县","奉节县","巫山县","巫溪县","石柱土家族自治县","秀山土家族苗族自治县","酉阳土家族苗族自治县","彭水苗族土家族自治县"],
    "四川": ["成都","自贡","攀枝花","泸州","德阳","绵阳","广元","遂宁","内江","乐山","南充","眉山","宜宾","广安","达州","雅安","巴中","资阳","阿坝藏族羌族自治州","甘孜藏族自治州","凉山彝族自治州"],
    "贵州": ["贵阳","六盘水","遵义","安顺","铜仁","毕节","黔西南布依族苗族自治州","黔东南苗族侗族自治州","黔南布依族苗族自治州"],
    "云南": ["昆明","曲靖","玉溪","保山","昭通","丽江","普洱","临沧","楚雄彝族自治州","红河哈尼族彝族自治州","文山壮族苗族自治州","西双版纳傣族自治州","大理白族自治州","德宏傣族景颇族自治州","怒江傈僳族自治州","迪庆藏族自治州"],
    "西藏": ["拉萨","昌都","山南地区","日喀则","那曲地区","阿里地区","林芝"],
    "陕西": ["西安","铜川","宝鸡","咸阳","渭南","延安","汉中","榆林","安康","商洛"],
    "甘肃": ["兰州","嘉峪关","金昌","白银","天水","武威","张掖","平凉","酒泉","庆阳","定西","陇南","临夏回族自治州","甘南藏族自治州"],
    "青海": ["西宁","平安","海晏","同仁","共和","玛沁","玉树","德令哈市"],
    "宁夏": ["银川","石嘴山","吴忠","固原","中卫"],
    "新疆": ["乌鲁木齐","克拉玛依","吐鲁番","哈密地区","昌吉回族自治州","博尔塔拉蒙古自治州","巴音郭楞蒙古自治州","阿克苏地区","克孜勒苏柯尔克孜自治州","喀什地区","和田地区","伊犁哈萨克自治州","塔城地区","阿勒泰地区"],
    "台湾": ["台北","高雄","基隆","台中","台南","新竹","嘉义","新北","宜兰县","桃园县","苗栗县","彰化县","南投县","云林县","屏东县","台东县","花莲县","澎湖县"],
    "香港": ["中西区东区","九龙城区","观塘区","南区","深水埗区","黄大仙区","湾仔区","油尖旺区","离岛区","葵青区","北区","西贡区","沙田区","屯门区","大埔区","荃湾区","元朗区"],
    "澳门": ["花地玛堂区","圣安多尼堂区","望德堂区","大堂区","风顺堂区","离岛","氹仔","路环"],
    "海外": ["美国","英国","法国","俄罗斯","加拿大","巴西","澳大利亚","印尼","泰国","马来西亚","新加坡","菲律宾","越南","印度","日本","其他"]
};

function in_user_show() {
    var uid = $('#uid').val() * 1;

    if(!uid || uid == 'NaN' || uid == last_uid) {
        return;
    }

    $('#no_user').hide();
    $('#user_show').hide();

    $.get('?c=admin&a=getUserInfo&uid=' + uid, function(data){
        var data = eval("(" + data + ")");
        if(!data.nickname) {
            $('#no_user').show();
        } else {
            $('#user_header').attr({'src': data.header});
            $('#user_name').text(data.nickname);
            $('#user_show').show();
        }

        last_uid = uid;
    });
}

function in_province() {
    var province = $('#province');
    var province_de = $('#province_de').val();

    for(var i in provinces) {
        province.append('<option value="' + provinces[i] + '">' + provinces[i] + '</option>');
    }

    is_in_province = true;

    if(province_de) {
        $("#province option[text='" + province_de + "']").attr("selected", "selected");
        $("#province option:contains('" + province_de + "')").attr("selected", "selected");

        $('#province').change();
    }
}

function in_city() {
    if(!is_in_province) {
        return;
    }

    var city = $('#city');
    var city_de = $('#city_de').val();
    var province = $("#province").find("option:selected").text();
    var cityList = citys[province];
    var maxIndex = $("#city option").length;

    if(maxIndex > 1) {
        for(var i = 1; i < maxIndex; i++) {
            $("#city option:last").remove();
        }
    }

    for(var i in cityList) {
        city.append('<option value="' + cityList[i] + '">' + cityList[i] + '</option>');
    }

    if(province_de) {
        $("#city option[text='" + city_de + "']").attr("selected", "selected");
        $("#city option:contains('" + city_de + "')").attr("selected", "selected");
    }
}

</script>

{template footer}